package com.ruoyi.report.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.report.domain.ReportBenefit;
import com.ruoyi.report.mapper.ReportBenefitMapper;
import com.ruoyi.report.service.IReportBenefitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ReportBenefitServiceImpl extends ServiceImpl<ReportBenefitMapper, ReportBenefit> implements IReportBenefitService {

    @Override
    public List<ReportBenefit> selectBenefitReportList(ReportBenefit reportBenefit) {
        return baseMapper.selectBenefitReportList(reportBenefit);
    }

    @Override
    public List<ReportBenefit> selectReportBenefitList(ReportBenefit reportBenefit) {
        return baseMapper.selectReportBenefitList(reportBenefit);
    }

    @Override
    public List<ReportBenefit> selectReportBenefitContentList(ReportBenefit reportBenefit) {
        return baseMapper.selectReportBenefitContentList(reportBenefit);
    }

    @Override
    public void clockReportBenefitList(String reportMonth) {
        ReportBenefit reportBenefit = new ReportBenefit();
        reportBenefit.setBenefitMonth(reportMonth);
        List<ReportBenefit> reportBenefits = baseMapper.selectBenefitReportList(reportBenefit);
        for(ReportBenefit benefit : reportBenefits) {
            benefit.setBenefitMonth(reportMonth);
            benefit.setCreateTime(DateUtils.getNowDate());
            baseMapper.insert(benefit);
        }
    }
}
